package com.appkubes.portal.admin.application.customer.controller;

import com.appkubes.common.Response;
import com.appkubes.portal.admin.application.customer.entity.vo.CustomerAppAddVO;
import com.appkubes.portal.admin.application.customer.entity.vo.CustomerAppGetVO;
import com.appkubes.portal.admin.application.customer.service.CustomerAppService;
import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.portal.core.controller.BasePortalCustomerAppController;
import com.appkubes.portal.core.entity.PortalCustomerApp;
import com.appkubes.portal.core.entity.PortalGlobalApp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "平台用户应用")
@RestController
@RequestMapping("/customer/app")
public class CustomerAppController extends BasePortalCustomerAppController {
    @Resource
    CustomerAppService appService;

    @ApiOperation("应用列表")
    @GetMapping("/get")
    public Response<List<PortalCustomerApp>> get(CustomerAppGetVO customerAppGetVO) {
        QueryWrapper<PortalCustomerApp> queryWrapper=new QueryWrapper();
        queryWrapper.eq("customer_key",customerAppGetVO.getCustomerKey());
        return Response.success(appService.list(queryWrapper));
    }

    @ApiOperation("添加应用")
    @PostMapping("/add")
    public Response add(@ParamValid CustomerAppAddVO appAddVO) {
        Boolean flag = appService.add(appAddVO);
        return Response.success(flag);
    }

}
